<template>
  <div class="page">
    <!-- 顶部栏 -->
    <van-nav-bar fixed placeholder :border="false">
      <template #title>
        <div class="fz-16 fw-bold">商品详情</div>
      </template>
    </van-nav-bar>

    <div class="container cl-white pt-30">
      <div class="flex flex-center">
        <img
          class="opacity radius mb-30"
          style="width: 283px; height: 170px"
          :src="detail.img"
        />
      </div>

      <div class="ta-center lh-2 mb-30">
        <div>
          <div class="fz-18 fw-bold">{{ detail.name }}</div>
          <div class="price">{{ detail.price }}克</div>
          <div class="fz-12">手工费：{{ detail.fees }}</div>
          <div class="fz-12">剩余：{{ detail.stock }}件</div>
        </div>
      </div>

      <div class="mb-30">
        <div class="fz-18 fw-bold mb-30">商品介绍</div>
        <div class="mb-30">{{ detail.description || '暂无介绍' }}</div>
        <div class="flex flex-center">
          <img
            class="opacity radius mb-30"
            style="width: 283px; height: 170px"
            :src="detail.introduceImg"
          />
        </div>
      </div>

      <div class="flex flex-center">
        <van-button type="primary">支付</van-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import goldApi from 'js/gold.api'

const route = useRoute()
const detail = ref({})

getProductDetail()

async function getProductDetail() {
  const params = {
    id: route.query.id,
  }

  const { code, data } = await goldApi.getProductDetail(params)

  if (code === 200) {
    detail.value = data
  }
}
</script>

<style lang="scss" scoped></style>
